package EA.testproblems;
import EA.*;

/*
  Colville function

  Created: 29. sept. 1999
  @version 1.0
  @author Rene Thomsen
*/

public class Colville extends NumericalProblem 
{

  // Easier way to build max and min
    private double[][] lmax = new double[0][2];
    private double[][] lmin = {{1,1,1,1}};

    public Colville()
    {
      super();

      double[] optimas;

      name = "Colville function";
      objectivefunction = new NumericalFitness(){
	      public double Fitness_calcFitness_inner(double[] realpos)
	      {
		  return 100*Math.pow((realpos[1]-realpos[0]*realpos[0]),2) +
		      Math.pow((1-realpos[0]),2) + 90*Math.pow(realpos[3]-realpos[2]*realpos[2],2)
		      + Math.pow(1-realpos[2],2) + 
		      10.1*(Math.pow(realpos[1]-1,2) + Math.pow(realpos[3]-1,2)) + 
		      19.8*(realpos[1]-1)*(realpos[3]-1);
	      };
	  };

      dimensions = 4;
      ismaximization = false;
      optimumradius = 0.2;

      intervals = new Interval[4];
      intervals[0] = new Interval(-10, 10);
      intervals[1] = new Interval(-10, 10);
      intervals[2] = new Interval(-10, 10);
      intervals[3] = new Interval(-10, 10);

      // Set up known maximas
      knownmaxima = new NumericalOptimum[lmax.length];

      for (int i=0;i<lmax.length;i++) {
	optimas = new double[dimensions];
	optimas[0] = lmax[i][0];
	optimas[1] = lmax[i][1];
	knownmaxima[i] = new NumericalOptimum(optimas, objectivefunction.calcFitness(optimas), true, false, i);
      }

      // Set up known minimas
      knownminima = new NumericalOptimum[lmin.length];

      for (int i=0;i<lmin.length;i++) {
	optimas = new double[dimensions];
	optimas[0] = lmin[i][0];
	optimas[1] = lmin[i][1];
	knownminima[i] = new NumericalOptimum(optimas, objectivefunction.calcFitness(optimas), false, false, i);
      }
    }
}
